<?php
	$yourCart 	= new Zend_Session_Namespace('cart');
	$carInfo 	= $yourCart->getIterator();
	$arrCart 	= $carInfo['cart'];
	
	$xhtml 		= '';
	if(!empty($this->arrColor)){
		foreach ($this->arrColor as $k => $v) {
			$name = Zendvn_Filter_Filter::filterContent($this->colorData[$v], 'filter');
			
			$quantity = $this->arrStock[$v];
			if(!empty($arrCart)){
				foreach ($arrCart as $ke => $va){
					if($va['id'] == $this->arrParam['product_id'] && $va['size'] == $this->arrParam['size_id'] && $va['color'] == $v){
						$quantity = $this->arrStock[$v] - $va['quantity'];
					}
				}
			}
			$xhtml .= '<li quantity="' . $quantity . '" stt="' . $v . '">' . $name . '</li>';
		}
	}
	echo $xhtml;
?>


<script>
	$(document).ready(function(){
		$("#choose_color li").click(function(){
			var color_id = $(this).attr('stt');
			var quantity = $(this).attr('quantity');
			$("#choose_color li").removeClass();
			$(this).addClass('active');
			$('#hidden_color').val(color_id);
			$('#choose_color').parent().removeClass('group-error');

			$('.stock-quantity').html('Hàng trong kho: <b id="maxQuantity">' + quantity + '</b>').hide().fadeIn();
			$('.stock-quantity').attr('id', quantity);
		})
	})
</script>